#ifndef NETWORKDIAGNOSEWIDGET_H
#define NETWORKDIAGNOSEWIDGET_H

#include <QDialog>
#include <QProcess>
#include <QListWidget>
#include <QLabel>
#include <QPushButton>
#include <QString>
#include "networkinfo.h"

#define POLICY_ROUTE_CONF "/etc/btwise-policy-routes.conf"
#define POLICY_ROUTE_DISPATCHER "/etc/NetworkManager/dispatcher.d/99-btwise-policy-routes"

class NetworkDiagnoseWidget : public QDialog {
    Q_OBJECT
public:
    explicit NetworkDiagnoseWidget(const ConnectionInfo &connInfo, const DeviceInfo &devInfo, QWidget *parent = nullptr);
private slots:
    void startDiagnose();
    void handleProcessOutput();
    void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
    void onStepClicked(QListWidgetItem* item);
    void onCopyReport();
private:
    void runNextStep();
    void updateStep(int idx, const QString &result, const QIcon &icon);
    void showSummary();
    QLabel *summaryLabel;
    QListWidget *stepList;
    QPushButton *retryButton;
    QPushButton *closeButton;
    QPushButton *copyButton;
    QProcess *process;
    QStringList diagnoseSteps;
    QStringList stepTitles;
    QStringList stepRawOutputs;
    int currentStep = 0;
    ConnectionInfo m_connInfo;
    DeviceInfo m_devInfo;
    QString m_baseInfoHtml;
    bool hasError = false;
};

#endif // NETWORKDIAGNOSEWIDGET_H 